package com.xiaolin.spring.annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Optional;

/**
 * @ClassName ADemoTest
 * @Description TODO
 * @Detail 基于注解的配置
 * @Author MyPC
 * @Date 2020/10/27
 * @Version 1.0
 */
public class ADemoTest4 {

    @Autowired
    @Qualifier("m1")  //用于区分多个相同类型的bean，可用于属性、方法参数上
    private MultBean multBean;

    @Autowired
    private MultBean multBean2;

    public static void main(String[] args) {
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("a-demo-test.xml");
        ADemoTest4 aDemoTest4 = applicationContext.getBean("ad4", ADemoTest4.class);
        System.out.println(aDemoTest4.multBean);
        System.out.println(aDemoTest4.multBean2);
    }
}
